const express =require('express');
const ejs = require('ejs');
const data =require('./data/newdata.json')

const app = express();

app.set('views',__dirname+'/html');
app.engine('html',ejs.renderFile);

app.listen(80);

app.get('/',(req,res)=>{
    res.render('list.html',{data})
})

app.get('/list',(req,res)=>{
    res.redirect('/')
})

app.get('/detail',(req,res)=>{
    let {id} = req.query;

    let obj = data.find(item=>item.id===id)

    res.render('detail.html',{obj})
})